﻿//-----------------------------------------------------------------------------------------
// <copyright file="OpticalMouse.cs" company="Jakub Florczyk (www.jakubflorczyk.pl)">
//      Copyright © 2009 Jakub Florczyk (www.jakubflorczyk.pl)
//      http://samsungmobilesdknet.codeplex.com
// </copyright>
//-----------------------------------------------------------------------------------------

namespace SamsungMobileSDKNET
{
    using System.Runtime.InteropServices;

    /// <summary>
    /// Specifies the operation mode of the optical mouse.
    /// </summary>
    public enum OpticalMouseMode
    {
        /// <summary>
        /// Cursor mode.
        /// </summary>
        Cursor,

        /// <summary>
        /// Navigation mode.
        /// </summary>
        Navigation,
    }

    /// <summary>
    /// Specifies the mouse speed in cursor mode.
    /// </summary>
    public enum OpticalMouseSpeed
    {
        /// <summary>
        /// Slow speed.
        /// </summary>
        Slow,

        /// <summary>
        /// Normal speed.
        /// </summary>
        Normal,

        /// <summary>
        /// Fast speed.
        /// </summary>
        Fast
    }

    /// <summary>
    /// Specifies the optical mouse capabilities.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct OpticalMouseCapabilities
    {
        /// <summary>
        /// Multi operation mode is supported.
        /// </summary>
        public bool MultiOperationModeIsSupported;

        /// <summary>
        /// Speed change is supported.
        /// </summary>
        public bool SpeedChangeIsSupported;
    }

    /// <summary>
    /// Samsung Optical Mouse API.
    /// </summary>
    /// <remarks>
    /// This optical mouse API functions allow the programmer to set and get the optical mouse operation mode and mouse speed.
    /// </remarks>
    public class OpticalMouse
    {      
        /// <summary>
        /// Gets optical mouse capabilities.
        /// </summary>
        /// <param name="capabilities">A pointer to the capabilities of the device.</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is NULL
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if an optical mouse is not found
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiOpticalMouseGetCapabilities")]
        public static extern ResultCode GetCapabilities(
            [Out] out OpticalMouseCapabilities capabilities);

        /// <summary>
        /// Sets the optical mouse operation mode.
        /// </summary>
        /// <param name="mode">Desired mouse operation mode.</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is invalid
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if an optical mouse is not found
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiOpticalMouseSetMode")]
        public static extern ResultCode SetMode(
            [In] OpticalMouseMode mode);

        /// <summary>
        /// Gets the optical mouse operation mode.
        /// </summary>
        /// <param name="mode">A pointer to the optical mouse operation mode.</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is NULL
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if an optical mouse is not found
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiOpticalMouseGetMode")]
        public static extern ResultCode GetMode(
            [Out] out OpticalMouseMode mode);

        /// <summary>
        /// Sets the Optical mouse speed in cursor mode.
        /// </summary>
        /// <param name="speed">Desired mouse speed.</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is invalid
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if an optical mouse is not found
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiOpticalMouseSetSpeed")]
        public static extern ResultCode SetSpeed(
            [In] OpticalMouseSpeed speed);

        /// <summary>
        /// Gets the optical mouse speed.
        /// </summary>
        /// <param name="speed">A pointer to the optical mouse speed.</param>
        /// <returns>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.Success"/> on success
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorInvalidParameter"/> if the input parameter is NULL
        /// <br/>
        /// <see cref="F:SamsungMobileSDKNET.ResultCode.ErrorDeviceNotFound"/> if an optical mouse is not found 
        /// </returns>
        [DllImport(Common.DllName, EntryPoint = "SmiOpticalMouseGetSpeed")]
        public static extern ResultCode GetSpeed(
            [Out] out OpticalMouseSpeed speed);       
    }
}
